class Solution:
    def searchInsert(self, nums: list[int], target: int) -> int:
        print(len(nums))
        if len(nums)==1:
                if nums[0]>=target:
                    return 0
                else:return 1
        elif len(nums)==2:
            if nums[1]<target:
                return 2
            elif (nums[0]==target and nums[1]>target) or nums[0]>target :
                return 0
            else:
                return 1
        else:
            for i in range(len(nums)):
            
                if nums[0]>=target:
                    return 0
                    break
                elif nums[len(nums)-1]<target:
                    return len(nums)
                    break
                elif nums[i]==target:
                        return i
                        break
                elif nums[i]<target and nums[i+1]>target:
                        return i+1
                        break
a=Solution()
print(a.searchInsert([1,3,5],5))